# Maintainer: Luca Weiss <luca@z3ntu.xyz>
pkgname=net-cpp
pkgver=3.0.0
pkgrel=4
pkgdesc="A simple yet beautiful networking API for C++11"
url="https://gitlab.com/ubports/core/lib-cpp/net-cpp"
arch="all"
license="LGPL-3.0-only"
makedepends="cmake cmake-extras boost-dev curl-dev process-cpp-dev
	properties-cpp-dev jsoncpp-dev gtest-dev samurai"
checkdepends="py3-httpbin"
subpackages="$pkgname-dev"
source="https://gitlab.com/ubports/core/lib-cpp/net-cpp/-/archive/$pkgver/net-cpp-$pkgver.tar.gz
	python-init.patch
	0001-curl-multi-handle-timer_callback-correctly.patch
	0002-curl-multi-fix-timer_callback-behavior-with-0-timeou.patch
	"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		$CMAKE_CROSSOPTS .
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
c8728f0bdc6ccb14edf4f6b6c7ec4381796aa4f40ced0b5ea58494db31a52e5e785816704e932aa34a993e6e7edc4826739755abcbfcea69990ba5505fc465e6  net-cpp-3.0.0.tar.gz
b67b50f159438513f8744daec4cce23d335025cd5c213534c36e59a29e2aac4ecf749487ad73f855971a8431bbde514e295918177b6d07d253b901aaa28d8582  python-init.patch
57880dad0b7a939d6d5be57c4025966615ba95444ae1ba7a8bc25cdbc78202adf308fc452d52465ef0764c4a71383f61c6079fc8dfd57c6892501dc4c29a36da  0001-curl-multi-handle-timer_callback-correctly.patch
4b09e519e3a9b82cf36843a9483383a8c75763fc19b137a5bdf707db57543abd5193d70dd835d6155a6717ae9e4d577243fd25944322f42287a48465d7e98052  0002-curl-multi-fix-timer_callback-behavior-with-0-timeou.patch
"
